---
description: "Reference for Nitric's v0 JVM library - Retrieves the value from a version of a secret."
---

# JVM - secret.version.access()

Retrieves the value from a version of a secret.

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var contents = secrets.latest().access();

    System.out.println(contents.toString());

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val contents = secrets.latest().access()

  println(contents.toString())

  Nitric.run()
}
```

</TabItem>

</Tabs>

## Examples

### Access the latest version of a secret

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var contents = secrets.latest().access();

    System.out.println(contents.toString());

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val contents = secrets.latest().access()

  println(contents.toString())

  Nitric.run()
}
```

</TabItem>

</Tabs>

### Access a specific version of a secret

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;

public class Application {
  public static void main(String[] args) {
    var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);

    var contents = secrets.version("the-version-id").access();

    System.out.println(contents.toString());

    Nitric.INSTANCE.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.resources.SecretPermission

fun main() {
  val secrets = Nitric.secret("encryptionKey").with(SecretPermission.Access)

  val contents = secrets.version("the-version-id").access()

  println(contents.toString())

  Nitric.run()
}
```

</TabItem>

</Tabs>
